/**
 * 
 */
package com.util;

import java.util.HashMap;
import java.util.Map;

public class Singleton {

	protected synchronized static Singleton getInstance(String name)
	{
		if (name == null)
		{
			name = Singleton.class.getName();
			System.out.println("name == null"+"--->name="+name);
		}
		
		if (map.get(name) == null)
		{
			try {
				map.put(name, (Singleton) Class.forName(name).newInstance());
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
		}
		return map.get(name);
	}
	
	protected Singleton()
	{
		
	}
	
	private static Map<String, Singleton> map = new HashMap<String, Singleton>();
	static 
	{
		map.put(Singleton.class.getName(), new Singleton());
	}
}
